package com.esunny.fptree;

public class Item implements Comparable<Item> {

    /**
     * 名
     */
    private String   name     = "";
    /**
     * 数量
     */
    private int      count    = 0;
    /**
     * 保存前缀树中，同名结点，他们之间的联系
     */
    private TreeNode linkNode = null;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public void incrCount(int n) {
        this.count += n;
    }

    @Override
    public int compareTo(Item arg0) {
        int count0 = arg0.getCount();
        // 跟默认的比较大小相反，导致调用Arrays.sort()时是按降序排列
        return count0 - this.count;
    }

    public TreeNode getLinkNode() {
        return linkNode;
    }

    public void setLinkNode(TreeNode linkNode) {
        this.linkNode = linkNode;
    }

}
